package console

import (
	"duoke/model"
	"duoke/service"
	"duoke/utils/gconv"
	"duoke/utils/request"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
)

var Area = new(areaCtl)

type areaCtl struct{}

func (ctl *areaCtl) Area(c *gin.Context) {
	req := request.JsonMap(c)
	var area model.ReqArea
	if gconv.Int(req["province"]) != 0 {
		area.Province = gconv.Int(req["province"])
	}
	if gconv.Int(req["city"]) != 0 {
		area.City = gconv.Int(req["city"])
	}
	list, err := service.Area.List(&area)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", list)

}
